<svg style="display: block; width: 0; height: 0">
  <defs>
    <filter id="drop-shadow">
    <fegaussianblur in="SourceAlpha" stdDeviation="0"></fegaussianblur>
    <feoffset dx="0" dy="10" result="offsetblur"></feoffset>
    <feflood flood-color="rgba(0,0,0,1)"></feflood>
    <fecomposite in2="offsetblur" operator="in"></fecomposite>
      <femerge>
        <femergenode></femergenode>
        <femergenode in="SourceGraphic"></femergenode>
      </femerge>
    </filter>
  </defs>
</svg>
<script>
var canvas = document.createElement('canvas');
canvas.width = 100;
canvas.height = 100;
var ctx = canvas.getContext('2d');
ctx.filter = 'url(#drop-shadow)';
ctx.fillStyle = '#0f0';
ctx.fillRect(25, 25, 50, 40);
document.body.appendChild(canvas);
</script>
